<?php
/**
 * Created by PhpStorm.
 * User: 勇林
 * Date: 2016/1/6
 * Time: 10:22
 */

namespace app\api\controllers;


use app\api\Constant;
use app\api\Response;
use app\common\utils\QyWechat;
use yii\web\Controller;

class JssdkController extends Controller
{

    /**
     * 获取JsApi使用签名
     */
    public function actionGetSignPackage($url){

        $options = array(
            'token'=>'gky',   //填写应用接口的Token
            'encodingaeskey'=>Constant::$GKY_AESKEY,//填写加密用的EncodingAESKey
            'appid'=>Constant::$GKY_CORPID,  //填写高级调用功能的appid
            'appsecret'=>Constant::$GKY_SECRET, //填写高级调用功能的密钥
        );
        $weObj = new QyWechat($options);
        $jssign = $weObj->getJsSign($url);
        $result = [];
        if($jssign != false){
            $result['status'] = 0;
            $result['signPackage'] = $jssign;
        }else{
            $result['status'] = -1;

        }
        Response::setHeader();
        echo json_encode($result);
    }

}